clear, clc
rng('shuffle')
n = input('');
X = randi([0, 9], n, 1);
for i = 2 : n
    while sum(X(i) == X(1 : i - 1))
        X(i) = randi([0, 9]);
    end
end
a = 0;
x = zeros(n, 1);
while a ~= n
    a = 0;
    xx = input('');
    while 1
        if xx >= 10 ^ (n - 2) && xx <= 10 ^ (n + 1)
            for i = 1 : n
                x(i) = mod(floor(xx / 10 ^ (n - i)), 10);
            end
            m = 0;
            for i = 1 : n
                m = m + sum(x(i) == x);
            end
            if m == n
                break
            end
        end
        disp('Error!')
        xx = input('');
    end
    m = 0;
    for i = 1 : n
        if x(i) == X(i)
            a = a + 1;
        end
        m = m + sum(x(i) == X);
    end
    b = m - a;
    disp([num2str(a), 'A', num2str(b), 'B'])
end